package com.neuedu.yyzx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.common.CommonResult;
import com.neuedu.yyzx.entity.NurseContent;
import com.neuedu.yyzx.service.INurseContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 护理内容 前端控制器
 * </p>
 *
 * @author dya
 * @since 2021-04-27
 */
@RestController
@RequestMapping("//nurseContent")
public class NurseContentController {

    @Autowired
    INurseContentService nurseContentService;
    @RequestMapping("/list")
    CommonResult list(Page page, NurseContent nurseContent){
        QueryWrapper queryWrapper = new QueryWrapper();
        if(nurseContent!= null && StringUtils.isNotEmpty(nurseContent.getContentName())){
            queryWrapper.like("content_name",nurseContent.getContentName());
        }
        return CommonResult.success(nurseContentService.page(page,queryWrapper));
    }
    @RequestMapping("/add")
    CommonResult add(NurseContent nurseContent){
        return CommonResult.success(nurseContentService.saveOrUpdate(nurseContent));
    }
    @RequestMapping("/update")
    CommonResult update(NurseContent nurseContent){
        return CommonResult.success(nurseContentService.updateAll(nurseContent));
    }

    @RequestMapping("/getById")
    CommonResult getById(Integer contentId){
        return CommonResult.success(nurseContentService.getById(contentId));
    }

    @RequestMapping("/del")
    CommonResult del(Integer contentId){
        return CommonResult.success(nurseContentService.removeById(contentId));
    }


}
